<template>
	<view class="content">
		<uni-icons class="sousuo" type="search"size="20"></uni-icons>
		<input placeholder="搜索歌曲" v-model="container" @input="sousuo"/>
		<uni-icons v-show="show" @click="clear" class="del" type="closeempty" size="20"></uni-icons>
	</view>
</template>

<script>
	export default {
		props:['searchWord','historysitem'],
		watch:{
			searchWord(newValue, oldVal) {
				this.container = newValue
				this.sousuo()
			},
			historysitem(newValue, oldVal) {
				this.container = newValue
				this.sousuo()
			}
		},
		data() {
			return {
				show:false,
				container:''
			}
		},
		methods:{
			sousuo(){
				if(this.container == '' || this.container == null || this.container == undefined){
					this.show = false
					this.$emit('sousuo2')
					//console.log('aaaaa')
				}else{
					this.show = true
					this.$emit('sousuo',this.container)
				}
			},
			clear(){
				this.container = '',
				this.$emit('clear')
				this.show = false
			}
		}
	}
</script>

<style lang="scss">
	.content{
		width: 100%;
		height: 80rpx;
		justify-content: center;
		align-items: center;
		display: flex;
		margin-bottom: 40rpx;
		.sousuo{
			margin-right: 10rpx;
		}
		input{
			width: 80%;
			//border-radius: 100rpx;
			border: 2rpx solid #e6e6e6;
			background-color:#e6e6e6 ;
			//margin-left: 10rpx;
		}
		.del{
			position: absolute;
			right: 60rpx;
		}
	}
</style>
